package com.testing.Utlis;

import java.util.LinkedHashMap;
import java.util.Map;

public class IniReadTest {

    public static final String backupUrlFile = "src/main/resources/config/element.ini";

    public static void main(String[] args) {
        IniReadTest iniReadTest = new IniReadTest();


        // 使用工具类读取ini文件返回map
        Map<String, String> map = null;
        map = IniUtils.readIniFile(backupUrlFile);
        if (!map.isEmpty()) {
            // 读取id信息
            String id = map.get("Login");
            // 读取name信息
            String name = map.get("test_url");
            String username = map.get("username");
            // 创建对象
            System.out.println(id);
            System.out.println(name);
            System.out.println(username);
//                Result resultData = new Result(id,name);
        }
        iniReadTest.writeIni(backupUrlFile, "page", "username", "test02");
    }

    /**
     * 写入ini文件数据
     *
     * @param title   标题,
     * @param urlPath ini存放位置
     */
    public void writeIni(String urlPath, String title, String key, String value) {


        LinkedHashMap<String, Object> map = new LinkedHashMap<>();
        map.put(key, value);
        // 使用工具类进行写入  ini文件的路径，数据头，存放的数据
        IniUtils.writeIniFile(urlPath, title, map);
    }

}
